<!-- 单个商品 -->
<template>
	<view class="SingleProduct por">
		<!-- 骨架 -->
		<view class="skeleton poa app-left app-top" v-if="loading">
			<u-skeleton :loading="loading" avatar rows="4" :title="false" avatarSize="260rpx"
				:rowsWidth="['402rpx','96rpx','212rpx','168rpx']"
				:rowsHeight="['72rpx','24rpx','36rpx','48rpx']"></u-skeleton>
		</view>
		<view class="goods-ali">
			<u--image width="260rpx" height="260rpx" radius="20rpx" src="https://cdn.uviewui.com/uview/album/1.jpg">
				<view slot="error" style="font-size: 24rpx;">加载失败</view>
			</u--image>
			<view class="goods-wai between height100 por" :class="{'border-bottom': !border}">
				<view>
					<view class="box2 margin-bottom-16">
						<text class="font-weight-400 color0 size-30">400g~500g/个丨【大果】黄脆甜玉米</text>
					</view>
					<view class="size-24 font-weight-400">
						<text class="color ">坏了包退</text>
						<text class="margin-left-20 color9">已卖2000个</text>
					</view>
				</view>
				<view>
					<view class="descent-top por dis-ali">
						<view class="descent-backs border dis-ali background">
							<view class="descent font-weight-400 size-24 color-f">直降1.0元</view>
							<view class="quota f-background font-weight-400 size-24 color">限购2个</view>
						</view>
						<text class="iconfont icon-xiala color size-34 poa"></text>
					</view>
					<view class="dis-cen">
						<view class="font-weight-600 size-28 color">
							采购价<text class="price-font">¥</text>
							<text class="size-44">{{onPriceCut('5',0)}}</text>
							<text class="size-40">.</text>
							<text class="size-36">{{onPriceCut('5.98',1)}}</text>
						</view>
					</view>
				</view>
			</view>
			<view class="carts-dis poa">
				<div class="ball-box" v-if="border == borderIndex">
					<div class="ball"></div>
				</div>
				<view class="add-cart background dis" @click="onAddCart(border)">
					<text class="color-f  font-weight-400 size-28">加入购物车</text>
				</view>
				<view class="dis-ali text-align">
					<view class="u-number-box__minus dis" @click="onAddCart($event)">
						<text class="iconfont icon-jian size-28 color"></text>
					</view>
					<input disabled type="text" class="u-number-box__input" v-model="value" />
					<view class="u-number-box__plus dis" @click="onAddCart($event)">
						<text class="iconfont icon-jia size-28 color-f"></text>
					</view>
				</view>
				<!-- <u-number-box v-model="value" @change="onAddCart($event,1)"></u-number-box> -->
			</view>
			<view class="poa dians background radius100" :style="{left:detailX,top:detailY}"></view>
		</view>
	</view>
</template>

<script>
	import { onPriceCut } from '@/utils/index';
	export default {
		props: {
			border: {
				type: Boolean,
				default: false
			},
			loading: {
				type: Boolean,
				default: true
			}
		},
		data() {
			return {
				borderIndex: 0,
				value: 0,
				detailX: 0,
				detailY: 0
			}
		},
		methods: {
			onPriceCut,
			onAddCart(index) {
				this.borderIndex = index
				// console.log(e, en)
				// this.detailX = e.detail.detailX
				// this.detailY = e.detail.detailY
			}
		}
	}
</script>

<style lang="scss">
	::v-deep.SingleProduct {
		padding-left: 20rpx;

		.goods-ali {
			display: grid;
			grid-template-columns: 260rpx 1fr;
			grid-column-gap: 20rpx;
			height: 292rpx;
			align-items: center;
		}

		.descent-top {
			margin-bottom: 24rpx;

			.descent-backs {
				border-radius: 6rpx;
				position: relative;
				z-index: 10;

				.descent {
					padding: 6rpx 6rpx;
				}

				.quota {
					padding: 6rpx 4rpx;
					border-top-right-radius: 6rpx;
					border-bottom-right-radius: 6rpx;
				}
			}

			.icon-xiala {
				bottom: -20rpx;
				left: 18rpx;
			}
		}

		.add-cart {
			width: 168rpx;
			height: 56rpx;
			border-radius: 8rpx;
		}

		.carts-dis {
			right: 16rpx;
			bottom: 20rpx;

			.ball-box {
				width: 20rpx;
				height: 20rpx;
				// background: red;
				position: absolute;
				top: 0rpx;
				right: 0;
				z-index: 100;
				animation: moveX 1s linear none;
			}

			.ball {
				width: 20rpx;
				height: 20rpx;
				background: red;
				position: absolute;
				right: 0;
				z-index: 100;
				animation: moveY 1s cubic-bezier(0.55, 0, 0.85, 0.36) none;
			}

			@keyframes moveX {
				to {
					transform: translateX(-351px);
				}
			}

			@keyframes moveY {
				to {
					transform: translateY(600px);
				}
			}
		}

		.goods-wai {
			box-sizing: border-box;
			padding: 16rpx 0;
			padding-right: 12rpx;
		}

		// 骨架
		.skeleton {
			z-index: 80;
			padding: 16rpx;
			background: #ffffff;
		}
	}
</style>